package org.xamp.gui.xmpp;

import java.util.ArrayList;

import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.RosterEntry;
import org.jivesoftware.smack.RosterGroup;
import org.jivesoftware.smack.XMPPConnection;

public class ContactList {
	
	private XMPPConnection xmppConnection;
	
	public ContactList(XMPPConnection xmppConnection) {
		this.xmppConnection = xmppConnection;
	}
	
	public ArrayList<String> getGroupList() {
		Roster roster = xmppConnection.getRoster();
		ArrayList<String> groupList = new ArrayList<String>();
		for (RosterGroup g : roster.getGroups()) {
			groupList.add(g.getName());
		}
		return groupList;
	}
	
	public ArrayList<String> getEntryList() {
		Roster roster = xmppConnection.getRoster();
		ArrayList<String> entryList = new ArrayList<String>();
		for (RosterEntry e : roster.getEntries()) {
			entryList.add(e.getName());
		}
		return entryList;
	}
	
	public RosterGroup getGroupByName(String groupName) {
		return xmppConnection.getRoster().getGroup(groupName);
	}
}
